<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>协同后台管理系统</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>
<body>
<div class="wrapper wrapper-content">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<%--<div class="ibox-title">
					<h5 onClick="prompt.confirm({sure:function(){alert(11)}})">资讯管理</h5>
				</div>--%>
				<div class="ibox-content">
					<div class="row">

						<div class="col-md-4" style="margin-bottom: 15px; margin-top: 5px;">
							<div class="input-group col-md-4">
								<a href="${ctx}/cms/article/form?parentId=${categoryId}"  class="btn btn-success btn-outline"  >
									<i class="fa fa-file-text-o"></i> 创建内容
								</a>
							</div>
						</div>

					<form:form id="searchForm" modelAttribute="article" action="${ctx}/cms/article/" method="post" >
						<div class="col-md-8" style="margin-bottom: 15px; margin-top: 5px;">
							<div class="input-group col-md-12">
								<input type="text" name="title" class="input-w-m form-control" value="${title}" id ="title" placeholder="请输入资讯标题" />
								<span class="input-group-btn">
								     	<button type="submit" class="btn btn-primary"> 搜索</button>
									</span>
							</div>
							<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
							<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
							<input type="hidden" value="${categoryId}" id="categoryId" name="categoryId"/>
						</div>
					</form:form>
					</div>
					<table class="table table-bordered">
						<thead>
						<tr>
							<th>标题</th>
							<th class="cuisine" style="position: relative">
								类目
							</th>
							<>
							<th>创建时间</th>
							<th colspan="2">操作</th>
						</tr>
						</thead>
						<tbody>

						<c:forEach items="${page.list}" var="article">
							<tr>
								<td><a href="${ctx}/cms/article/form?id=${article.id}" title="${article.title}">${fns:abbr(article.title,40)}</a></td>
								<td>
										${article.category.name}
								</td>
								<td><fmt:formatDate value="${article.updateDate}" type="both"/></td>
								<td class="operation">
									<a  class="btn btn-sm" href="${ctx}/cms/article/form?id=${article.id}&parentId=${categoryId}">修改</a>
									<%--<c:if test="${article.remarks == 1}">
										<a class="btn btn-sm demo4"
										   data-param1="${ctx}/cms/article/recommend?id=${article.id}&remarks=0"
										   data-param2="确定取消推荐吗？">取消推荐位</a>
									</c:if>
									<c:if test="${article.remarks != 1}">
										<a class="btn btn-sm demo4"
										   data-param1="${ctx}/cms/article/recommend?id=${article.id}&remarks=1"
										   data-param2="确定设为推荐吗？">设为推荐位</a>
									</c:if>--%>
									<a class="btn btn-sm demo4"
									   data-param1="${ctx}/cms/article/delete?id=${article.id}"
									   data-param2="确定删除吗？">删除</a>
								</td>
							</tr>
						</c:forEach>


						</tbody>
					</table>

					<div class="row">
						${page}
					</div>

				</div>
			</div>
		</div>

	</div>
</div>

<script src="${ctxStatic}/js/plugins/sweetalert/sweetalert.min.js"></script>
<script>
    $(".demo4").click(function(){
        var param1=$(this).data("param1");//url
        var param2=$(this).data("param2");//title
        prompt.confirm({
            title:param2,
            sure:function () {
                $.ajax({
                    url:param1,
                    success:function () {
                        prompt.info();
                        setTimeout(function () {
                            window.location.reload();
                        },1000)
                    }
                })
            }
        });

	});

</script>
</body>
</html>
